<?php	/* gmslOpenSource 2008 */
/*
----------------------------------------------------------------------------------------
	Project name:		gmslappcore
	Section:		login
----------------------------------------------------------------------------------------
	Script name:		login.php
	Script location:	./gmslappcore/pages/
	Script version:		1.0
----------------------------------------------------------------------------------------
	Script info:		This is the page where users will be able to login to
						the system so that they can enter secure sections of
						the site.
	Script dependencies:
 				~None.
----------------------------------------------------------------------------------------
	This script is part of the gmslappcore system which is released
	under the GNU licese.
	Copyright: (c) 2008 Andrew Cornford (groupmsl.co.uk)
	Email: projects@groupmsl.co.uk
	Website: www.groupmsl.co.uk?section=cms&page=view&t=gmslappcore&f=groupmsl Open Source/gmslappcore
----------------------------------------------------------------------------------------
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------------------
*/
// PHP early scripts go here.
$page['title']="Login";
$page['info']="Please login using your username and password created for this website, once you are logged in you can change your password and other information and continue to use the site.";

// Calling the skin head.
eval($page['skin_head']);

// Head HTML goes here.

// Calling the skin header.
eval($page['skin_header']);

// Content PHP and HTML goes here.
// Checking to see if the user has already entered there login info.
if($_POST['go']=='1')
	{
	// Selecting the user from the database.
	$page['login_query']=mysql_query("SELECT username, password, type, banned, fullname FROM $database[users] WHERE username='$_POST[username]'");
	$page['login_result']=mysql_fetch_assoc($page['login_query']);

	// If the user does not exist or the password does not match the database password for that user, it gives an error message.
	if((!$page['login_result']['username'])||($_POST['password']!=$page['login_result']['password'])) include($errors['location'].'wrong_login.php');

	// If the user is banned then they will not be allowed to login in, and an error message will pop up.
	elseif($page['login_result']['banned']=='Y') include($errors['location'].'youre_banned.php');
	else
		{
		$_SESSION['gmslappcore_skin_mode']=$_POST['skin_mode'];
		$_SESSION['gmslappcore_username']=$page['login_result']['username'];
		$_SESSION['gmslappcore_logged_in']='TRUE';
		$_SESSION['gmslappcore_user_type']=$page['login_result']['type'];
		$_SESSION["gmsl_user_fullname"]=$page['login_result']['fullname'];
		include($settings['gmslappcore_location'].'login/good_login.php'); ?>
		<p class="system_minitext">You are being redirected to: 
		<?php if(isset($_POST['page_go']))
			{ ?>
			Your last page. (<?php echo $_POST['page_go']; ?>)</p>
			<meta http-equiv="Refresh" content="2;url=<?php echo $_POST['page_go']; ?>" />
			<?php }
		else
			{ ?>
			The homepage.</p>
			<meta http-equiv="Refresh" content="2;url=<?php echo $_SERVER['PHP_SELF']; ?>" />
			<?php }
		}
	}
// Checking to see if login form already filled in. If it is not:
else include($settings['gmslappcore_location'].'login/main_login_page.php');

// Calling the skin footer.
eval($page['skin_footer']); ?>
